{%include file="header.html"%}
<style>
th{ text-align:left;}
</style>
<body>
<div class="fixed-bar">
  <div class="item-title">
    <h3>自定义导航</h3>
    <div style="background:rgba(251,112,45,1);width:125px;height:40px;float:right;text-align:center;border-radius:5px;">
          <a href="nav_list.php?act=add">
            <h5 style="padding:10px;color:#fff;">添加导航</h5>
          </a>
    </div>
  </div>
</div>
<div class="fixed_bottom">
    <table align="center;" class="table tb-type2">
      <thead>
        <tr>
          <th width="10"></th>
          <th width="50"><a>编号</a></th>
          <th width="25%"><a>名称</a></th>
          <th><a>是否显示</a></th> 
          <th><a>是否新窗口</a></th>
          <th><a>排序</a></th>
          <th><a>位置</a></th>
          <th width="10%"><a>操作</a></th>
        </tr>
      </thead>
      <tbody>
      	{%foreach from=$nav_list item=list%}
      	<tr>
          <td></td>
          <td>{%$list.id%}</td><!--编号-->
          <td>{%$list.name%}</td><!--名称-->
          <td><i style="cursor:pointer;" onclick="ajax_enabled(this,{%$list.id%},{%$list.ifshow%})" class="fa {%if $list.ifshow eq 1%}fa-close {%else%}fa-check{%/if%}"></i></td>
          <td><i style="cursor:pointer;" onclick="ajax_new(this,{%$list.id%},{%$list.opennew%})" class="fa {%if $list.opennew eq 1%}fa-close {%else%}fa-check{%/if%}"></i></td>
          <td>{%$list.vieworder%}</td><!--排序-->
          <td>{%if $list.type eq middle%}
                中间
              {%/if%}
              {%if $list.type eq top%}
                上
              {%/if%}
              {%if $list.type eq bottom%}
                下
              {%/if%}
          </td><!--位置-->
          <td>
            <a href="nav_list.php?act=add&id={%$list.id%}">编辑</a>
            <a href="nav_list.php?act=ads_del&id={%$list.id%}">删除</a>
          </td>
        </tr>
        {%/foreach%}
      </tbody>
    </table>
    <div class="page">{%$page%}</div>
</div>
</body>
<script>
function ajax_enabled(obj,id,price){
  if(price==1){
    prices="1";
  }else{
    prices="2";
  }
  $.post("nav_list.php",{act:'ajax_enabled',id:id,show:prices},function(data){
      if(data==1){
      layer.msg("操作成功！");
      if(prices==1){
        $(obj).attr("onclick","ajax_enabled(this,"+id+",2)");
        $(obj).removeClass("fa-close");
        $(obj).addClass("fa-check");
      }else if(prices==2){
        $(obj).attr("onclick","ajax_enabled(this,"+id+",1)");
        $(obj).removeClass("fa-check");
        $(obj).addClass("fa-close");
      }
    }else if(data==2){
      layer.msg("操作失败！");
    }
  });  
}
function ajax_new(obj,id,price){
  if(price==1){
    prices="1";
  }else{
    prices="2";
  }
  $.post("nav_list.php",{act:'ajax_new',id:id,news:prices},function(data){
      if(data==1){
      layer.msg("操作成功！");
      if(prices==1){
        $(obj).attr("onclick","ajax_new(this,"+id+",2)");
        $(obj).removeClass("fa-close");
        $(obj).addClass("fa-check");
      }else if(prices==2){
        $(obj).attr("onclick","ajax_new(this,"+id+",1)");
        $(obj).removeClass("fa-check");
        $(obj).addClass("fa-close");
      }
    }else if(data==2){
      layer.msg("操作失败！");
    }
  });  
}
</script>
</html>
